let sceneMain2 = null;
let sceneChartMain2 = null;

function init3Dcharts(a,b) {
   
    var towerHight = 20;
    var timerKpi;
    var level = parseFloat(Math.random() * 20).toFixed(2);
    // if (level >= 20) {
    //     level = 2.99;
    // }
    var dataLista = parseFloat(a * 100 / towerHight).toFixed(2);

    var dataListb = parseFloat(b * 100 / towerHight).toFixed(2);
    //渲染图表;
  
    makeBar(dataLista, a, getBgColor(a), "onehaochartsId");
    makeBar(dataListb, b, getBgColor(b), "onehaochartsId1");

    clearInterval(timerKpi);

    // setInterval(function () {
    //     getInitData();
    // }, 1000);
}

function getBgColor(num) {
    var min = '1', max = '2';
    if (num > max) {
        return '#3EC6F0'
    }

    if (num >= min && num <= max) {
        return '#3EC6F0'
    }

    if (num < min) {
        return '#3EC6F0'
    }
}

function makeBar(dataList, level, colorList, id) {
    var myChart = echarts.init(document.getElementById(id))
    var option = {
        tooltip: {
            trigger: 'none'
        },
        xAxis: {
            data: [''],
            axisTick: {
                show: false
            },
            axisLine: {
                show: false
            },
            axisLabel: {
                show: false
            }
        },
        yAxis: {
            splitLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLine: {
                show: false
            },
            axisLabel: {
                show: false
            }
        },
        series: [{
            name: '最上层立体圆',
            type: 'pictorialBar',
            animation: false,
            symbolSize: [100, 45],
            symbolOffset: [0, -20],
            z: 12,
            itemStyle: {
                normal: {
                    color: '#363F5E'
                }
            },
            
            data: [{
                value: 100,
                symbolPosition: 'end'
            }]
        }, {
            name: '中间立体圆',
            animation: false,
            type: 'pictorialBar',
            symbolSize: [100, 45],
            symbolOffset: [0, -20],
            z: 12,
            itemStyle: {
                normal: {
                    color: colorList
                }
            },
            label: {
                show: true,
                position:['10%', '-20%'],
                color: "#FFFE00",
                fontSize: 24,
                formatter: function () {
                    return level + "米";
                }
            },
            data: [{
                value: dataList,
                symbolPosition: 'end'
            }]
        }, {
            name: '最底部立体圆',
            animation: false,
            type: 'pictorialBar',
            symbolSize: [100, 45],
            symbolOffset: [0, 20],
            z: 12,
            itemStyle: {
                normal: {
                    color: colorList
                }
            },
            data: [100 - dataList]
        }, {
            //底部立体柱
            stack: '1',
            animation: false,
            type: 'bar',
            itemStyle: {
                normal: {
                    color: colorList,
                    opacity: .7
                }
            },
            // label: {
            //     show: true,
            //     position:['10%', '-30%'],
            //     color: "#FFFE00",
            //     fontSize: 24,
            //     formatter: function () {
            //         return level + "米";
            //     }
            // },
            silent: true,
            barWidth: 100,
            barGap: '-100%', // Make series be overlap
            data: [dataList]
        }, {
            //上部立体柱
            stack: '1',
            type: 'bar',
            animation: false,
            itemStyle: {
                normal: {
                    color: '#36405E',
                    opacity: .7
                }
            },
            silent: true,
            barWidth: 100,
            barGap: '-100%', // Make series be overlap
            data: [100 - dataList]
        }]
    };

    myChart.setOption(option);
}


// width 1716  height 560

